home *** CD-ROM | disk | FTP | other *** search
- Newsgroups: comp.lang.c++
- Path: wn.planet.gen.nz!news
- From: hugp@kp.planet.gen.nz (Peter Hug)
- Subject: [Q] Missinterpreting *protected* access modifier?
- X-Newsreader: Forte Free Agent 1.0.82
- Reply-To: hugp@kp.planet.gen.nz
- Sender: news@wn.planet.gen.nz (news)
- Organization: Maxi Solutions Ltd
- Message-ID: <DLrCGF.G1F@wn.planet.gen.nz>
- Date: Thu, 25 Jan 1996 23:11:17 GMT
-
- Am I missinterpreting the meaning of the *protected* access modifier?
- The following code does not compile under VC++:
-
- ============================================
- class A
- {
- protected:
- int i;
- int GetInt() { return i; };
- };
-
- class B : public A
- {
- protected:
- int Foo(A * pA) { return pA->GetInt(); };
- };
- ============================================
-
- The error I'm getting is on the line declaring B::Foo(): error C2248:
- 'GetInt' : cannot access protected member declared in class 'A'
-
- My C++ bible knows the following about the protected keyword: "When
- preceding a list of class members, the protected keyword specifies that
- those members are accessible only from member functions and friends of
- the class and its derived classes."
- ^^^^^^^^^^^^^^^
- According to this definition, B should have access to A::GetInt().
-
- Cheers
-
-
- +-------------------------------------------------------------------+
- + Peter Hug mailto://hugp@kp.planet.gen.nz +
- + Maxi Solutions Ltd http://kp.planet.gen.nz/users/hugp +
- + PO Box 1468 +
- + Paraparaumu Beach Phone: +64 4 297-0463 +
- + New Zealand Fax: +64 4 297-0465 +
- +-------------------------------------------------------------------+
-
-